<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet"
	href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<title>Fill comparing table</title>
</head>
<body>
<div class = "container">
	<h1>Results</h1>
	<form:form method="GET" commandName="tableResult"
		action="${pageContext.request.contextPath}/table/result">

		<table border="1">
						<tbody>
							<tr>
								<th></th>
								<c:forEach var="cr_name" items="${criteria}">
									<th>${cr_name.name}</th>
								</c:forEach>

								<th>Priority Vector</th>

							</tr>
							<c:forEach var="firm" items="${firms}" varStatus="i">
								<tr>
									<td>${firm.name}</td>
									<c:forEach var="cr_name" items="${criteria}" varStatus="j">
										<td>${mainResult.table[i.index][j.index]}</td>
									</c:forEach>
									<td>${mainResult.priorityVector[i.index] }</td>

								</tr>

							</c:forEach>

						</tbody>
					</table>


		<c:forEach var="table" items="${tableResult.tableList}" varStatus="k">

			
				<c:if test="${k.index == 0 }">
					<h1>Table result for criteria comparison</h1>

					<table border="1">
						<tbody>
							<tr>
								<th></th>
								<c:forEach var="cr_name" items="${criteria}">
									<th>${cr_name.name}</th>
								</c:forEach>

								<th>Row Sum</th>
								<th>Determined Vector</th>
								<th>Multiplication</th>
								<th>Priority Vector</th>

							</tr>
							<c:forEach var="cr_name" items="${criteria}" varStatus="i">
								<tr>
									<td>${cr_name.name}</td>
									<c:forEach var="cr_name" items="${criteria}" varStatus="j">
										<td>${table.table[i.index][j.index]}</td>
									</c:forEach>
									<td>${table.rowSum[i.index] }</td>
									<td>${table.detetminedVector }</td>
									<td>${table.multiplication[i.index] }</td>
									<td>${table.priorityVector[i.index] }</td>

								</tr>

							</c:forEach>

						</tbody>
					</table>
					<br />
				</c:if>
					
			
				<c:choose>
				<c:when test="${k.index != 0 }">
					<h1>Table result for ${criteria[k.index - 1].name}</h1>

					<table border="1">
						<tbody>
							<tr>
								<th></th>
								<c:forEach var="firm" items="${firms}">
									<th>${firm.name}</th>
								</c:forEach>

								<th>Row Sum</th>
								<th>Determined Vector</th>
								<th>Multiplication</th>
								<th>Priority Vector</th>

							</tr>
							<c:forEach var="firm" items="${firms}" varStatus="i">
								<tr>
									<td>${firm.name}</td>
									<c:forEach var="firm1" items="${firms}" varStatus="j">
										<td>${table.table[i.index][j.index]}</td>
									</c:forEach>
									<td>${table.rowSum[i.index] }</td>
									<td>${table.detetminedVector }</td>
									<td>${table.multiplication[i.index] }</td>
									<td>${table.priorityVector[i.index] }</td>

								</tr>

							</c:forEach>

						</tbody>
					</table>
					<br />
				</c:when>
			</c:choose>
		</c:forEach>


	</form:form>
	<a href="${pageContext.request.contextPath}/">Home page</a>
</div>
</body>
</html>